//
//  HomeClassroomCell.m
//  DefendHealth
//
//  Created by UNOHACHA on 17/2/20.
//  Copyright © 2017年 iMacOne. All rights reserved.
//

#import "HomeClassroomCell.h"

@implementation HomeClassroomCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 197)];
        bgView.backgroundColor = kWhiteColor;
        [self.contentView addSubview:bgView];
        
        UILabel *titNameL = [ReduceCode creatLabelWithFrame:CGRectMake(20, 20, 100, 30) title:@"我的设备" titleColor:UIColorFromRGB(0x333333) font:17 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:titNameL];
        
        UILabel *moreL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(bgView.frame)-200, 20, 180, 30) title:@"不同玩法让跑步不再枯燥" titleColor:UIColorFromRGB(0x999999) font:15 textAlignment:NSTextAlignmentRight];
        [bgView addSubview:moreL];
        
        UIImageView *iconImageView = [ReduceCode creatImageVeiwWithFrame:CGRectMake(20, kMaxY(titNameL.frame)+24, 100, 70) imageName:@"pic4" isCorner:NO];
        iconImageView.backgroundColor = [UIColor orangeColor];
        [bgView addSubview:iconImageView];
        
        UILabel *equipmL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(bgView.frame)-200, kMaxY(moreL.frame)+23, 180, 20) title:@"设备：无" titleColor:UIColorFromRGB(0x333333) font:15 textAlignment:NSTextAlignmentRight];
        [bgView addSubview:equipmL];
        
        UILabel *stateL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(bgView.frame)-200, kMaxY(equipmL.frame)+7, 180, 20) title:@"状态：未连接" titleColor:UIColorFromRGB(0x333333) font:15 textAlignment:NSTextAlignmentRight];
        [bgView addSubview:stateL];
        
//        UIView *butView = [[UIView alloc]initWithFrame:CGRectMake(20, kMaxY(iconImageView.frame)+15, kScreenWidth-40, 34)];
//        butView.backgroundColor = kWhiteColor;
//        butView.layer.cornerRadius = 15;
//        butView.clipsToBounds = YES;
////        butView.layer.borderWidth = 2;
////        butView.layer.borderColor = [UIColor orangeColor].CGColor;
//        [bgView addSubview:butView];
        
        UIImageView *butImageView = [ReduceCode creatImageVeiwWithFrame:CGRectMake(20, kMaxY(iconImageView.frame)+15, kScreenWidth-40, 34) imageName:@"pic6" isCorner:NO];
        butImageView.userInteractionEnabled = YES;
        [bgView addSubview:butImageView];
        
        CGFloat weight = butImageView.width/3;
        
//        NSArray *title = @[@"计划",@"启用",@"约跑"];
        for (int i = 0; i<3; i++) {
            UIButton *but = [UIButton creatBtnWithFrame:CGRectMake(weight*i, 0, weight, 34) btnTitle:nil btnTitleColor:nil btnTitleFont:15 btnTagPrice:i+10 btnSetImage:nil btnBackgroundColor:nil isCorner:NO action:^(UIButton *button) {
                
                if (_indexBlock) {
                    
                    _indexBlock(0);
                }
            }];
            [butImageView addSubview:but];
        }
    }
    
    return self;
}
- (void)oldView {
    UIView * bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 130)];
    
    
    bgView.backgroundColor = kWhiteColor;
    
    [self.contentView addSubview:bgView];
    
    UIView *hui = [UIView new];
    hui.frame = CGRectMake(0, 0,WindowWidth , 0.5);
    hui.backgroundColor = kLineColor;
    [bgView addSubview:hui];
    
    UIImageView * startImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(0, 0, 80, 30) imageName:@"background" isCorner:NO];
    //        startImg.backgroundColor = kRedColor;
    [bgView addSubview:startImg];
    
    UILabel * startL = [ReduceCode creatLabelWithFrame:CGRectMake(0,0,60, 14) title:@"跑步" titleColor:kWhiteColor font:14 textAlignment:NSTextAlignmentCenter];
    startL.center = startImg.center;
    [bgView addSubview:startL];
    
    UILabel * popuL = [ReduceCode creatLabelWithFrame:CGRectMake(kScreenWidth-70,12,60, 12) title:@"人气:1201" titleColor:UIColorFromRGB(0x333333) font:12 textAlignment:NSTextAlignmentLeft];
    [bgView addSubview:popuL];
    
    
    
    
    UIImageView * mainImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(kScreenWidth-90, kMaxY(popuL.frame)+12, 80, 80) imageName:@"" isCorner:NO];
    mainImg.backgroundColor = UIColorFromRGB(0xcccaca);
    [bgView addSubview:mainImg];
    
    
    UILabel * titNameL = [ReduceCode creatLabelWithFrame:CGRectMake(10, kMaxY(startImg.frame)+12, kScreenWidth-mainImg.width-30, 18) title:@"腿部拉伸" titleColor:UIColorFromRGB(0x333333) font:18 textAlignment:NSTextAlignmentLeft];
    [bgView addSubview:titNameL];
    
    UILabel * connectL = [ReduceCode creatLabelWithFrame:CGRectMake(titNameL.x, kMaxY(titNameL.frame)+12, titNameL.width, 14) title:@"轻松畅跑和粗腿说拜拜" titleColor:UIColorFromRGB(0x666666) font:14 textAlignment:NSTextAlignmentLeft];
    [bgView addSubview:connectL];
    
    UILabel * planL = [ReduceCode creatLabelWithFrame:CGRectMake(titNameL.x, kMaxY(connectL.frame)+20, titNameL.width/2, 14) title:@"时长:10分钟" titleColor:UIColorFromRGB(0x666666) font:14 textAlignment:NSTextAlignmentLeft];
    [bgView addSubview:planL];
    
    UILabel * rankL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(planL.frame)+12, kMaxY(connectL.frame)+20, titNameL.width/2, 14) title:@"难度:基础" titleColor:UIColorFromRGB(0x666666) font:14 textAlignment:NSTextAlignmentLeft];
    [bgView addSubview:rankL];
}

@end
